var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "序号"
		},{
			colkey : "tranDate",
			name : "日期",
			renderData : function(rowindex,data, rowdata, column) {
					return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "materialNo",
			name : "物料编码"
		},{
			colkey : "productName",
			name : "名称"
		},{
			colkey : "brand",
			name : "规格型号"
		},{
			colkey : "unit",
			name : "单位"
		},{
			colkey : "initialCount",
			name : "初期结存数量"
		},{
			colkey : "initialPrice",
			name : "平均价格"
		},{
			colkey : "initialTotal",
			name : "初期结算金额"
		},{
			colkey : "currentInCount",
			name : "本期收入数量"
		},{
			colkey : "currentInPrice",
			name : "平均单价"
		},{
			colkey : "currentInTotal",
			name : "本期收入金额"
		},{
			colkey : "currentOutCount",
			name : "本期发出数量"
		},{
			colkey : "currentOutPrice",
			name : "平均单价"
		},{
			colkey : "currentOutTotal",
			name : "本期发出金额"
		},{
			colkey : "finalBalCount",
			name : "末期结存数量"
		},{
			colkey : "finalBalPrice",
			name : "平均单价"
		},{
			colkey : "finalBalTotal",
			name : "末期结存金额"
		},{
			colkey : "reckoning",
			name : "盘点"
		},{
			colkey : "profitAndLoss",
			name : "盈亏"
		}],
		jsonUrl : rootPath + '/purLest/purLest_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	
	$("#addFun").click("click", function() {
		editAccount();
	});
	$("#delOrder").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "盘点",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/purLest/purlest_edit.shtml?id=' + cbox
	});
}


